<form id="<?php echo $uniqid;?>" method="post" style="padding: 8px;">
    <table border="0" width="100%" cellspacing="1" cellpadding="5" class="formtable">
        <tr>
            <td class="tlabel" width="20%">标题：</td>
            <td width="80%"><input name="title" type="text" style="width:400px;"
                                   class="forminput inputstyle validatebox-text textbox-prompt easyui-validatebox"
                                   placeholder="请输入标题.." required="true" v-model="params.title"></td>
        </tr>
        <tr>
            <td class="tlabel">类别：</td>
            <td width="80%">
                <template v-for="(vo,index) in imagesCat">
                    <label style="padding-right: 20px;"><input name="type" type="radio" class="textbox-prompt"
                                                               :value="vo.id" v-model="params.cat_id">{{vo.title}}</label>
                </template>
            </td>
        </tr>
        <tr v-if="params.cat_id==2">
            <td class="tlabel">广告链接：</td>
            <td width="80%"><input type="text" style="width:400px;"
                                   class="forminput inputstyle validatebox-text textbox-prompt easyui-validatebox"
                                   placeholder="请输入广告链接.." v-model="params.links"></td>
        </tr>
        <tr v-if="params.cat_id==2||params.cat_id==3">
            <td class="tlabel">关联商品ID：</td>
            <td width="80%"><input type="text" style="width:200px;"
                                   class="forminput inputstyle validatebox-text textbox-prompt easyui-validatebox"
                                   placeholder="请输入商品ID.." v-model="params.goods_id"></td>
        </tr>
        <tr>
            <td class="tlabel">排序：</td>
            <td width="80%"><input name="sortorder" type="text"
                                   class="forminput inputstyle validatebox-text textbox-prompt easyui-validatebox"
                                   placeholder="请输入排序.." v-model="params.sortorder"></td>
        </tr>
        <tr>
            <td class="tlabel">状态：</td>
            <td width="80%"><label><input name="status" type="checkbox" class="textbox-prompt" v-model="params.status">激活</label></td>
        </tr>
        <tr bgcolor="#FFFFFF">
            <td class="tlabel" >图片：</td>
            <td class="main" style="padding: 0">
                <div title="上传图片" style="display: flex; height: 80px; overflow: hidden;">
                    <div class="col-md-12" v-if="params.image">
                        <a class="linkWrapper" target="_blank" :href="params.image" title="查看原图">
                            <img height="70px" :src="params.image+'?imageView2/1/w/100/h/100'" style="border-radius: 5px;"></a>
                    </div>
                    <div class="col-md-12">
                        <div style="background-color:#F9F9F4">
                            <a class="btn btn-default btn-lg" href="#"
                               style="text-decoration: none;padding:20px;display: flex;" @click="uploadBox('imageseditVm.params.image')">
                                <div style="padding-right: 10px;">选择图片</div> <i class="iconfont icon-tianjia"></i>
                            </a>
                        </div>
                    </div>
                </div>
            </td>
        </tr>
    </table>
</form>
<script>
    var imageseditVm = new Vue({
        el: '#<?php echo $uniqid;?>',
        data: {
            params: JSON.parse('<?php echo addslashes($dataset);?>'),
            imagesCat: [],
        },
        mounted(){
            $.post('/admin/images/imagesCat', {}, function (data) {
                imageseditVm.imagesCat = data.rows;
            });
        },
        methods: {
            submit(){
                imageseditVm.params.status = imageseditVm.params.status ? 1 : 0;
                let act = imageseditVm.params.id>0 ? 'edit' : 'add';
                $.post('/admin/images/'+act, imageseditVm.params, function (data) {
                    if (parseInt(data.ret) === 0) {
                        $.messager.show({
                            title: '提示',
                            msg: data.msg,
                            timeout: 3000,
                            showType: 'slide'
                        });
                        $('#imageseditfm').form('clear');
                        $("#imagesdlg").dialog('close');
                        $("#images").datagrid('reload');
                    } else {
                        $.messager.alert('提示', data.msg, 'warning');
                    }
                }, 'json');
            },
            rm() {
                $.messager.confirm('确认对话框', '您确认删除么？', function (r) {
                    if (r) {
                        imageseditVm.params.image = '';
                    }
                });
            }
        }
    });
    $(function () {
        $('#imagessubmit').click(function () {
            imageseditVm.submit();
        });
    });
</script>
